package com.example.smartg;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.example.smartg.utils.ToastUtil;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.util.List;

import okhttp3.Call;
import okhttp3.Response;

public class LvAdapterHistory extends BaseAdapter {
    private Context context;
    private LayoutInflater layoutInflater;
    private List<Order> records;

    public LvAdapterHistory(Context context, List<Order> records) {
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        this.records = records;
    }

    @Override
    public int getCount() {
        return this.records.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    static class ViewHolder {
        public TextView index;
        public TextView batch_num;
        public TextView material_num;
        public TextView material_quantity;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (view == null) {
            view = layoutInflater.inflate(R.layout.lv_item_history, null);
            viewHolder = new ViewHolder();
            viewHolder.index = (TextView) view.findViewById(R.id.index);
            viewHolder.batch_num = (TextView) view.findViewById(R.id.batch_num);
            viewHolder.material_num = (TextView) view.findViewById(R.id.material_num);
            viewHolder.material_quantity = (TextView) view.findViewById(R.id.material_quantity);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
//        viewHolder.cb_item.setChecked(this.toDeletes.get(i));
        viewHolder.index.setText(this.records.get(i).index);
        viewHolder.batch_num.setText(this.records.get(i).batch_num);
        viewHolder.material_num.setText(this.records.get(i).material_num);
        viewHolder.material_quantity.setText(this.records.get(i).material_quantity);
        LvAdapterHistory self = this;
        return view;
    }

}
